package com.yunmang.adapter;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.yunmang.fragment.BaseFragment;

import java.util.List;

/**
 * 作者 : bean on 2017/4/5/0005.
 * 注释 :
 */
public class MyPagerAdapter extends FragmentPagerAdapter {
    private List<BaseFragment> fragments ;
    private String[] tabTitles=new String[]{"待派送","派送失败"};
    private String[] exceptionTitles=new String[]{"批次列表","车辆信息","库存记录"};
    private boolean isshow=false;
    public MyPagerAdapter(FragmentManager fm,List<BaseFragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }
    public MyPagerAdapter(FragmentManager fm,List<BaseFragment> fragments,boolean isshow) {
        super(fm);
        this.fragments = fragments;
        this.isshow=isshow;
    }


    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if(isshow)
            return exceptionTitles[position];
        return tabTitles[position];
    }
}